﻿using GraphProcessor;
using IQIGame.Onigao.Logic;
using UnityEngine;

namespace IQIGame.Onigao.GamePlay.Editors
{
    [System.Serializable, NodeMenuItem(SkillEditorConst.SkillEffective + "/" + SkillEditorConst.Package + "/" + SkillEditorConst.Damage, typeof(SkillEditorGraph))]
    public class EffectivePackageNode_Damage: EffectivePackageNode_Base
    {

        protected override ESkillEffectiveType actionType => ESkillEffectiveType.Damage;

        [Input("命中")] public SkillEffectiveAction_ParamBool hitFormula;
        [Input("暴击")] public SkillEffectiveAction_ParamBool critFormula;
        [Input("伤害")] public SkillEffectiveAction_ParamNum damageFormula;
        [InspectorName("检测死亡")] public bool checkDead = true;
        
        [Output("伤害值")] public SkillEffectiveAction_ParamNum damage;
        
        [Output("暴击")] public SkillEffectiveAction_ParamBool crit;

        protected override void Process()
        {
            if (this.self == null)
            {
                return;
            }
            base.Process();
            this.damage = new SkillEffectiveAction_ParamNum()
            {
                dataGuid = this.self.action.guid,
                key = BattleConst.FinalDamage,
            };
            this.crit = new SkillEffectiveAction_ParamBool()
            {
                dataGuid = this.self.action.guid,
                key = BattleConst.Crit
            };
        }

        protected override SkillCustomConfig CreateConfig()
        {
            var rConfig = new SkillEffectiveAction_Damage_ConfigData()
            {
                hit = this.hitFormula,
                crit = this.critFormula,
                damage = this.damageFormula,
                checkDead = this.checkDead
            };
            return rConfig;
        }
    }
}